package com.threeti.jiayusms.interfaces.ws.communicationvoice;

import static org.springframework.util.CollectionUtils.isEmpty;

import java.util.List;

import javax.jws.WebService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import com.threeti.jiayusms.domain.model.CommunicationRule;
import com.threeti.jiayusms.domain.model.CommunicationTime;
import com.threeti.jiayusms.domain.model.CommunicationVoice;
import com.threeti.jiayusms.domain.model.legacy.Condition;
import com.threeti.jiayusms.domain.model.legacy.ConditionType;
import com.threeti.jiayusms.domain.model.legacy.Node;
import com.threeti.jiayusms.domain.model.legacy.ProductType;
import com.threeti.jiayusms.domain.service.communicationrule.CommunicationRuleQueryService;
import com.threeti.jiayusms.domain.service.communicationtime.CommunicationTimeQueryService;
import com.threeti.jiayusms.domain.service.communicationvoice.CommunicationVoiceQueryService;
import com.threeti.jiayusms.domain.service.legacy.JiaYuDBLegacyQueryService;
import com.threeti.jiayusms.interfaces.facade.JiaYuSystemQueryFacade;

@WebService(serviceName = "VoiceTemplateService", portName = "VoiceTemplateServicePort",
		endpointInterface = "com.threeti.jiayusms.interfaces.ws.communicationvoice.VoiceTemplateWebService",
		targetNamespace = "http://127.0.0.1:8080/sms-maintenance-main" )
@Transactional
public class VoiceTemplateWebServiceDelegate implements VoiceTemplateWebService {

  @Autowired
  private JiaYuSystemQueryFacade queryFacade;

	//@Override
//	public CommunicationVoiceDto findCommunicationVoiceBy(String voiceId) {
//		CommunicationVoice voiceemplate = queryService.findCommunicationVoiceBy(voiceId);
//
//		if(voiceemplate == null){
//			return null;
//		}
//		CommunicationVoiceDto dto = new CommunicationVoiceDto(
//				voiceemplate.getVoiceContent(),
//				voiceemplate.getActiveFlag(),
//				voiceemplate.getVoiceDescription());
//
//		return dto;
//	}


	//
//	public List<CommunicationVoiceDto> findCommunicationVoiceByList(){
//		List<CommunicationVoiceDto> dto = new ArrayList<CommunicationVoiceDto>();
//
//		return dto;
//	}

  @Override
  public String getMessageBy(String orderid, String voiceTemplateId, String sendTimeId) {
    return queryFacade.getVoiceTemplateBy(orderid, voiceTemplateId, sendTimeId);
  }

  @Override
  public String getMessagePreviewBy(String nodeCode,
                                    String voiceTemplateId,
                                    String ruleTemplateId,
                                    String timeTemplateId,
                                    String productTypeCode,
                                    String conditionTypeCode,
                                    String conditionCode,
                                    String communicationEnable) {
    return queryFacade.getVoicePreviewBy(nodeCode, voiceTemplateId, ruleTemplateId, timeTemplateId, 
        productTypeCode, conditionTypeCode, conditionCode, communicationEnable);
  }
  
}
